var util = require('../../utils/util.js');
//获取应用实例
const app = getApp();
Page({
  data: {
    jiazai: 1,
    activity_id: '',
    total: '',
    page: 0,
    SeeList: [

    ]
  },
  onshow: function(hhh) {
    // app.seeLogin();
    // this.setData({
    //     activity_id: hhh.activity_id
    // });
    // this.getUserAvatar();
  },
  onLoad: function(hhh) {
    this.setData({
      activity_id: hhh.activity_id
    });
    this.getUserAvatar();

  },
  // 首次获取用户信息
  getUserAvatar: function() {
    var that = this;
    var num = wx.getStorageSync('accessToken');
    wx.request({
      url: 'https://wechat.wuyuzhong.com/api/join/users',
      data: {
        activity_id: that.data.activity_id
      },
      header: {
        'Content-Type': 'application/json',
        'Accept': 'application/json',
        Authorization: num,
        //   limited:1
      },
      success: function(res) {
        var avatar = [];
        var res = res.data.data;
        for (var i = 0; i < res.data.length; i++) {
          avatar.push({
            'SeeAddress': res.data[i].user.avatar
          })
        }
        that.setData({
          SeeList: avatar,
          total: res.total
        });
      }
    })
  },
  jiazaigengduo:function(){
    var that=this;
    var arr = that.data.SeeList;
    var num = wx.getStorageSync('accessToken');
    var page=that.data.page+1
    wx.request({
      url: 'https://wechat.wuyuzhong.com/api/join/users',
      data: {
        activity_id: that.data.activity_id,
        page:page
      },
      header: {
        'Content-Type': 'application/json',
        'Accept': 'application/json',
        Authorization: num,
        //   limited:1
      },
      success: function (res) {
        // var avatar = [];
        var res = res.data.data;
        for (var i = 0; i < res.data.length; i++) {
          arr.push({
            'SeeAddress': res.data[i].user.avatar
          })
        }
        that.setData({
          SeeList:arr,
          jiazai:that.data.jiazai+1,
          page:page
        })
      }
    })
  }
})